<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="Lsc">
    <title>原型练习</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
</html>
<script>
    
    function People(age){
        this.age=age;
    }

    // 公有属性
    People.prototype.name='Tom';
    People.prototype.isMale=true;
    People.prototype.birthdate=1995;
    // 公有方法
    People.prototype.eat=function(food){
        console.log(this.name+'吃了'+food);
    }
    People.prototype.sleep=function(hours){
        console.log(this.name+'睡了'+hours+'小时');
    }
    People.prototype.play=function(game){
         console.log(this.name+'玩了'+game);
     }
     People.prototype.study=function(content){
         console.log(this.name+'学习了'+content);
     }

    //  Baby 时期
    var Baby =new People('1');
     console.dir(Baby);
    Baby.eat('香蕉');
    Baby.sleep('16');

    // Child 时期
    var Child =new People('6');
    console.dir(Child);
    Child.eat('饺子');
    Child.sleep('10');
    Child.play('捉迷藏');

    //  Student 时期
     var Student=new People('16');
     console.dir(Student);
     Student.eat('米饭');
     Student.sleep('6');
     Student.play('篮球');
     Student.study('二次函数');

     //Worker 时期 
     var Worker=new People('22');
     console.dir(Worker);
     Worker.eat('面条');
     Worker.sleep('9');
     Worker.play('台球');
     Worker.study('面向对象编程');

    //  Worker 时期 私有属性和方法
     Worker.salary=10000;
     Worker.work=function(work){
        console.log(this.name+'的工作是'+work);
     }
     Worker.work('前端工程师');
     
</script>